﻿using NCP.Core;
using NCP.Core.Exceptions;
using NCP.Model;
using NCP.Service;
using NCP.Util;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.Mvc;
using WebApp.Filters;


namespace WebApp.Controllers
{
    public class LimitTimeController : Controller
    {
        private LimitTimeService _service;

        public LimitTimeController(LimitTimeService service)
        {
            _service = service;
        }
        public ActionResult Index()
        {
            return View();
        }
        //获取未限制药品信息 
        public ActionResult GetunLimitDrugInfo()
        {
            List<PhaBaseInfo> dataList = _service.GetunLimitDrugInfo();
            LayData ht = new LayData("0", "获取成功", dataList);
            return Content(JsonConvert.SerializeObject(ht));
        }
        //获取限制药品信息 
        public ActionResult GetLimitDrugInfo()
        {
            List<LimitTimeNew> dataList = _service.GetLimitDrugInfo();
            LayData ht = new LayData("0", "获取成功", dataList);
            return Content(JsonConvert.SerializeObject(ht));
        }
        //保存限制药品信息
        public ActionResult SaveLimiteTime(List<LimitTimeNew> items)
        {
            LayData data = new LayData("0", "保存成功");
            try
            {
                _service.SaveLimiteTime(items);
            }
            catch (Exception ex)
            {
                MessageException.CatchException(ex, data);
            }

            return Json(data);
        }
    }
}